package homework;

/**
 * @classname:RandomUtil
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/10 20:07
 * @version: 0.1
 * @since:1.8
 */
public class RandomUtil {
    private RandomUtil(){ }

    public static StringBuilder[] randomStr(int N){
        StringBuilder[] sbs = new StringBuilder[N];
        for (int i = 0; i < N; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < 4; j++) {
                //生成一个97-122之间的int类型整数--为了生成小写字母
                int intValL = (int)(Math.random()*26+97);
                //生成一个65-90之间的int类型整数--为了生成大写字母
                int intValU = (int)(Math.random()*26+65);
                //生成一个48-57之间的int类型整数--为了生成数字
                int intValN = (int)(Math.random()*10+48);
                int intVal = 0;
                int r = (int)(Math.random()*3);
                if(r==0) {
                    if(intValL==105 || intValL==108 || intValL==111){//排除小写 i o l
                        intValL = intValL+1;
                    }
                    intVal = intValL;
                }else if (r==1) {
                    if(intValU==79){//排除大写 O
                        intValU = intValU+1;
                    }
                    intVal = intValU;
                }else {
                    //如果是0,1 改成 2,3
                    if(intValN==48 || intValN==49){
                        intValN = intValN+2;
                    }
                    intVal = intValN;
                }
                sb.append((char) intVal);
            }
            sbs[i] = sb;
        }
        return sbs;

    }
    public static void main(String[] args) {
        StringBuilder[] stringBuilders = RandomUtil.randomStr(4);
        for (StringBuilder stringBuilder : stringBuilders) {
            System.out.println(stringBuilder.toString());
        }
    }
}
